﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="ISettingConfiguration.cs" company="DevDigital">
//   DevDigital
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

namespace Settings.NET
{
    /// <summary>
    /// Setting configuration
    /// </summary>
    public interface ISettingConfiguration
    {
        /// <summary>
        /// Sets the current scope
        /// </summary>
        /// <typeparam name="TScope">The type of the scope.</typeparam>
        /// <param name="scope">The scope.</param>
        /// <returns>The setting configuration</returns>
        ISettingConfiguration InScope<TScope>(TScope scope);

        /// <summary>
        /// Sets the current scope
        /// </summary>
        /// <param name="scope">The scope.</param>
        /// <returns>The setting configuration</returns>
        ISettingConfiguration InScope(string scope);

        /// <summary>
        /// Sets the current scope to the global scope
        /// </summary>
        /// <returns>The setting configuration</returns>
        ISettingConfiguration InGlobalScope();

        /// <summary>
        /// Sets the current storage
        /// </summary>
        /// <typeparam name="TStorage">The type of the storage.</typeparam>
        /// <returns>The setting configuration</returns>
        ISettingConfiguration WithStorage<TStorage>() where TStorage : ISettingsStorage, new();

        /// <summary>
        /// Sets the current storage.
        /// </summary>
        /// <param name="settingsStorage">The settings storage.</param>
        /// <returns>The setting configuration</returns>
        ISettingConfiguration WithStorage(ISettingsStorage settingsStorage);

        /// <summary>
        /// Sets the current caching.
        /// </summary>
        /// <typeparam name="TCache">The type of the cache.</typeparam>
        /// <returns>The setting configuration</returns>
        ISettingConfiguration WithCache<TCache>() where TCache : ISettingsCache, new();

        /// <summary>
        /// Sets the current caching.
        /// </summary>
        /// <param name="settingsCache">The settings cache.</param>
        /// <returns>The setting configuration</returns>
        ISettingConfiguration WithCache(ISettingsCache settingsCache);

        /// <summary>
        /// Sets the current serializer.
        /// </summary>
        /// <typeparam name="TSerializer">The type of the serializer.</typeparam>
        /// <returns>The setting configuration</returns>
        ISettingConfiguration WithSerializer<TSerializer>() where TSerializer : ISettingsSerializer, new();

        /// <summary>
        /// Sets the current serializer.
        /// </summary>
        /// <param name="settingsSerializer">The settings serializer.</param>
        /// <returns>The setting configuration</returns>
        ISettingConfiguration WithSerializer(ISettingsSerializer settingsSerializer);

        /// <summary>
        /// Gets the setting information, or the setting information with the specified default value if the setting is not in storage or there is a deserialization error.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="defaultValue">The default value.</param>
        /// <returns>The setting information, or the setting information with the specified default value if the setting is not in storage or there is a deserialization error</returns>
        ISetting<TValue> Get<TValue>(TValue defaultValue = default(TValue));

        /// <summary>
        /// Gets the setting information, or the setting information with the specified default value if the setting is not in storage or there is a deserialization error.
        /// </summary>        
        /// <param name="defaultValue">The default value.</param>
        /// <returns>The setting information, or the setting information with the specified default value if the setting is not in storage or there is a deserialization error</returns>
        ISetting<string> Get(string defaultValue = null);

        /// <summary>
        /// Gets the setting value, or the specified default value if the setting is not in storage or there is a deserialization error.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="defaultValue">The default value.</param>
        /// <returns>
        /// The setting value, or the specified default value if the setting is not in storage or there is a deserialization error
        /// </returns>
        TValue GetValue<TValue>(TValue defaultValue = default(TValue));

        /// <summary>
        /// Gets the setting value, or the specified default value if the setting is not in storage or there is a deserialization error.
        /// </summary>        
        /// <param name="defaultValue">The default value.</param>
        /// <returns>
        /// The setting value, or the specified default value if the setting is not in storage or there is a deserialization error
        /// </returns>
        string GetValue(string defaultValue = null);

        /// <summary>
        /// Sets the setting value.
        /// </summary>
        /// <typeparam name="TValue">The type of the value.</typeparam>
        /// <param name="value">The value.</param>
        void SetValue<TValue>(TValue value);

        /// <summary>
        /// Sets the setting value.
        /// </summary>
        /// <param name="value">The value.</param>
        void SetValue(string value);

        /// <summary>
        /// Removes the setting from storage.
        /// </summary>
        void Remove();
    }
}